package com.wdh.kjs.Adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wdh.kjs.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class UF_per_p_Adapter extends BaseAdapter {
    private List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
    private Context context;
    private HashMap<String, String> maps = new HashMap<String, String>();
    private int periods = 0;

    public UF_per_p_Adapter(Context context, List<HashMap<String, String>> data) {
        this.data = data;
        this.context = context;
    }

    public void resetData(List<HashMap<String, String>> data) {
        this.data.clear();
        this.data.addAll(data);
        this.notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return data.size();
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return data.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            maps = data.get(position);
            convertView = View.inflate(context, R.layout.upload_file_per_1_p, null);

            viewHolder.file_name = (TextView) convertView
                    .findViewById(R.id.file_name);
            viewHolder.file_size = (TextView) convertView
                    .findViewById(R.id.file_size);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.file_name.setText(maps.get("fileName"));
        viewHolder.file_size.setText(maps.get("fileSize"));
        return convertView;
    }
    private class ViewHolder {
        TextView file_name;
        TextView file_size;

    }


}
